package com.hutu.security;

import cn.hutool.core.date.DateUtil;
import com.SecurityProvider;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

public class JwtProvider implements SecurityProvider {

    @Override
    public String generateToken(Integer id, String password) {
        return JWT.create().withAudience(id.toString()) // 设置载荷
                .withExpiresAt(DateUtil.offsetHour(new Date(), 20)) // 设置签名过期的时间
                .sign(Algorithm.HMAC256(password)); // 签名 Signature
    }
}
